package cn.kingyang.yiyi.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jtech.view.JRecyclerView;

import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import cn.kingyang.yiyi.R;
import cn.kingyang.yiyi.mvp.model.bean.NobleVideo;
import cn.kingyang.yiyi.mvp.presenter.VideoInfoPresenter;
import cn.kingyang.yiyi.mvp.view.VideoInfoView;
import cn.kingyang.yiyi.ui.adapter.VideoPinglunAdapter;
import cn.kingyang.yiyi.utils.AppUtil;

/**
 * Created by Administrator on 2017/3/4.
 */

public class VideoInfoActivity extends BaseActivity<VideoInfoView, VideoInfoPresenter> implements VideoInfoView, View.OnClickListener {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.video_pic)
    ImageView videoPic;
    @BindView(R.id.video_pic1)
    ImageView videoPic1;
    @BindView(R.id.video_title)
    TextView videoTitle;
    @BindView(R.id.video_pic2)
    ImageView videoPic2;
    @BindView(R.id.video_title2)
    TextView videoTitle2;
    @BindView(R.id.pinglunjrv)
    JRecyclerView pinglunjrv;
    @BindView(R.id.video_pic3)
    ImageView videoPic3;
    @BindView(R.id.video_title3)
    TextView videoTitle3;
    @BindView(R.id.bofang)
    TextView bofang;
    private VideoPinglunAdapter mVideoAdapter;//
    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void onError(Throwable t) {

    }

    @Override
    protected VideoInfoPresenter getPresenter() {
        return new VideoInfoPresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_video_info;
    }

    @Override
    public void doVideoInfo(List<HashMap<String, String>> data) {
    mVideoAdapter.setDatas(data);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        NobleVideo nobleVideo= (NobleVideo) getIntent().getSerializableExtra("data");
        toolbar.setTitle(nobleVideo.getTitle());
        videoTitle.setText(nobleVideo.getTitle());
        videoTitle2.setText(getIntent().getStringExtra("title"));
        videoTitle3.setText(getIntent().getStringExtra("title1"));
        AppUtil.initImage(this,videoPic,nobleVideo.getThumb());
        AppUtil.initImage(this,videoPic1,nobleVideo.getThumb());
        AppUtil.initImage(this,videoPic2,getIntent().getStringExtra("pic"));
        AppUtil.initImage(this,videoPic3,getIntent().getStringExtra("pic1"));
        bofang.setText("播放:"+AppUtil.getRandom(10000,999999)+"次");
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        mVideoAdapter =new VideoPinglunAdapter(this);
        pinglunjrv.setLayoutManager(new GridLayoutManager(this,1));
        pinglunjrv.setAdapter(mVideoAdapter);
//        pinglunjrv.setOnItemClickListener(this);
        videoPic.setOnClickListener(this);
        videoPic1.setOnClickListener(this);
        videoPic2.setOnClickListener(this);
        mPresenter.getPinglunInfo();
    }


    @Override
    public void onClick(View view) {
        AppUtil.showPopupWindow(this,view);
    }
}
